package com.earl.util;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

/**
 * Created by 知鹏 on 2018/6/24.
 */
public class GsonUtil {

    public static String toJson(Object bean){
        Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
        return gson.toJson(bean);
    }

    public  static <T>T fromJson(String json,Class<T> beanClass){
        Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
        return gson.fromJson(json, beanClass);
    }
}
